package com.sz.common.core.system.service.impl;

import com.sz.common.base.dao.DaoSupport;
import com.sz.common.base.exception.BizException;
import com.sz.common.core.system.entity.UserLoginInfo;
import com.sz.common.core.system.service.UserLoginInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.ParseException;

/**
 * Function: UserConfigServiceImpl <br>
 * Author: xutao <br>
 * Date: 2016-10-31 10:51:00
 */
@Service
public class UserLoginInfoServiceImpl implements UserLoginInfoService {


    @Resource(name = "daoSupport")
    private DaoSupport dao;

    @Override
    public int updateUserLoginInfo(UserLoginInfo userLoginInfo) throws BizException, ParseException {

        UserLoginInfo uliTemp = (UserLoginInfo) dao.findForObject("UserLoginInfoMapper.selectByPrimaryKey", userLoginInfo.getUserName());

        if (uliTemp == null) {
            dao.save("UserLoginInfoMapper.insert", userLoginInfo);
        } else {
            dao.save("UserLoginInfoMapper.updateByPrimaryKey", userLoginInfo);
        }

        return 0;
    }

}
